package com.taotao.tools.validate.annotations.union;

import com.taotao.tools.validate.annotations.UnionConstraint;
import com.taotao.tools.validate.iface.impl.NotNullOnOtherFieldValueFieldValidator;

import javax.validation.Payload;
import java.lang.annotation.Documented;
import java.lang.annotation.Inherited;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;


/**
 * 与某个字段相等,必须在对象上加@UnionValids
 *
 * @author youbeiwuhuan
 */
@Inherited
@Target({TYPE})
@Retention(RUNTIME)
@Repeatable(NotNullOnOtherFeildValue.List.class)
@UnionConstraint(validatedBy = {NotNullOnOtherFieldValueFieldValidator.class})
@Documented
public @interface NotNullOnOtherFeildValue {

    /**
     * 指定相等的字段名称
     *
     * @return
     */
    String fieldName();

    String message() default "";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};


    @Inherited
    @Target({TYPE})
    @Retention(RUNTIME)
    @Documented
    @interface List {
        NotNullOnOtherFeildValue[] value();
    }

}
